<!DOCTYPE HTML>

<html>
<head>
<title>WebGL PremultipliedAlpha False Test</title>
<style type="text/css">
.nomargin {
  margin: 0px auto;
}
</style>

<script>
function sendResult(status, detail) {
  console.log(detail);
  if (window.domAutomationController) {
    window.domAutomationController.send(status);
  } else {
    console.log(status);
  }
}

var numFramesBeforeEnd = 15;

function main() {
  var canvas = document.getElementById("c");
  var gl = canvas.getContext(
      'webgl', { antialias: false, premultipliedAlpha: false });
  if (!gl) {
    sendResult("FAILURE", "WebGL context not supported");
    return;
  }

  // Clear the left half of the canvas to transparent red, assuming
  // non-premultiplied alpha.
  gl.scissor(0, 0, 150, 150);
  gl.enable(gl.SCISSOR_TEST);
  gl.clearColor(1.0, 0.0, 0.0, 0.4);
  gl.clear(gl.COLOR_BUFFER_BIT);
  gl.disable(gl.SCISSOR_TEST);
  window.requestAnimationFrame(waitForFinish);
}

function waitForFinish()
{
  if (--numFramesBeforeEnd == 0) {
    sendResult("SUCCESS", "Test complete");
  } else {
    window.requestAnimationFrame(waitForFinish);
  }
}
</script>
</head>
<body onload="main()">
<canvas id="c" width="300" height="150" class="nomargin" style="position:absolute; top:0px; left:0px; background-color: #008000;"></canvas>
</div>
</body>
</html>
